/**
 * 项目名称: Topic_107.cpp
 * 项目路径: study/DataStructure/LeetCode/树/中等
 * 编辑时间: 2024年08月16日08时47分30秒
 * 用   户: 轻尘
 */

#include <bits/stdc++.h>

using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;

    TreeNode() : val(0), left(nullptr), right(nullptr) {}

    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

class Solution {
public:
    vector<vector<int>>ve;
    vector<int>init;

    void pre(TreeNode* root,int study){
        if(root){
            study++;
            if(ve.size()<=study)ve.push_back(init);
            if(root->left){
                ve[study].push_back(root->left->val);
                pre(root->left,study);
            }

            if(root->right){
                ve[study].push_back(root->right->val);
                pre(root->right,study);
            }
        }
    }
    vector<vector<int>> levelOrderBottom(TreeNode* root) {
        if(!root)return ve;
        ve.push_back(init);
        ve[0].push_back(root->val);
        pre(root, 0);
        ve.pop_back();
        reverse(ve.begin(),ve.end());
        return ve;
    }
};

int main() {

    return 0;
}
